package com.dimples.common.enums;

import com.dimples.common.constant.StrPool;

import java.util.Set;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2021/6/26
 */
public enum ViewEnum {

    // ================================================= 页面 ================================================= //
    /**
     * login
     */
    LOGIN("login"),
    /**
     * index
     */
    INDEX("index"),
    /**
     * console
     */
    CONSOLE("console/console"),
    /**
     * 403
     */
    ACCESS_DENY_URL("error/403"),

    /**
     * user
     */
    USER("system/user/main"),
    USER_EDIT("system/user/main"),
    USER_ADD("system/user/add"),

    /**
     * menu
     */
    MENU("system/menu/main"),
    MENU_ADD("system/menu/add"),
    MENU_EDIT("system/menu/edit"),

    /**
     * menu
     */
    ROLE("system/role/main"),
    ROLE_ADD("system/role/add"),
    ROLE_EDIT("system/role/edit"),
    ROLE_POWER("system/role/power"),

    //
    ;

    @Setter
    @Getter
    private String value;

    public static Set<String> values = CollUtil.newHashSet();

    ViewEnum(String value) {
        this.value = value;
    }

    // 供免认证配置,跟controller层访问名称一致
    static {
        ViewEnum[] viewEnums = ViewEnum.values();
        if (viewEnums.length > 0) {
            for (ViewEnum viewEnum : viewEnums) {
                String[] val = StrUtil.split(viewEnum.value, StrPool.SLASH);
                values.add(StrPool.SLASH + val[val.length - 1]);
            }
        }
    }
}
